<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>javascript 阶段</title>
    <style>
        
    </style>
</head>
<body>


    <script>
        var dt1 = new Date();
        console.log(dt1);
        var startTime = dt1.getTime();
        console.log(startTime);

        var dt2 = new Date("2021-10-01");
        console.log(dt2);
        var endTime = dt2.getTime();
        console.log(endTime);

        var time = (endTime - startTime) /1000;
        var day = Math.floor(time/60/60/24);
        var hours = Math.floor(time/60/60 % 24);
        var minutes = Math.floor(time % 3600 / 60);
        var seconds = Math.floor(time % 60);

        var str = "<h1>距离国庆还有"+day+'天'+hours+'小时'+minutes+'分钟'+seconds+'秒'+"</h1>"
        document.write(str);
    </script>
</body>
</html>